<?php
/**
 * @category ContentEngine
 * @package Goatherd\Content\Engine
 *
 * @author Copyright (c) 2012 Maik Penz <maik@phpkuh.de>
 * @version $Id: IItem.php 77 2012-03-27 07:53:54Z maik@phpkuh.de $
 *
 * This file is part of Goatherd library.
 *
 * Goatherd library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Goatherd library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Goatherd library. If not, see <http://www.gnu.org/licenses/>.
 */
namespace Goatherd\Content\Engine\Queue;

use Goatherd\Content\Engine\Source\ISource;

use Goatherd\Commons\Model\IModel;

/**
 *
 * @category ContentEngine
 * @package Goatherd\Content\Engine
 * @subpackage Queue
 */
interface IItem
extends IModel
{
    /**
     * Get associated source object.
     *
     * @return AbstractSource
     */
    public function getSource();

    /**
     *
     * @param ISource $source
     * @throws Exception
     */
    public function setSource(ISource $source);

    /**
     * Get unique identifier as used by source/ reader.
     *
     * @return mixed
     */
    public function getIdentifier();

    /**
     *
     * @param string $id
     * @throws Exception
     */
    public function setIdentifier($id);

    /**
     *
     * @return ItemCollection
     */
    public function getRelatedItems();

    /**
     *
     * @return \Goatherd\Content\Engine\Resource.IResource
     */
    public function getResource();

    /**
     * Sanity check.
     *
     * @return boolean
     */
    public function isValid();

    /**
     * Check if object data changed since last call to persist().
     *
     * @return boolean
     */
    public function isClean();

    /**
     * Write item (create or update).
     *
     * @return int queue id
     * @throws \ContentEngine\Writer\Exception on writer error
     * @throws \ContentEngine\Exception on data (validation) error
     */
    public function persist();
}